package cjos.util;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

/**
 *
 * @author Jos
 */
public class ASCIIArt {

    public static void main(String[] args) throws IOException {

        int width = 100;
        int height = 30;

        BufferedImage image = ImageIO.read(new File("C:/Users/aaaa/Desktop/ascii-artaa.png"));
//        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = image.getGraphics();
        g.setFont(new Font("SansSerif", Font.BOLD, 24));

        Graphics2D graphics = (Graphics2D) g;
        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        graphics.drawString("JAVA", 10, 20);

                    //save this image
        ImageIO.write(image, "png", new File("C:/Users/aaaaaa/Desktop/ascii-art.png"));
        
        
//        System.out.println(""+Integer.valueOf("FFFFFF", 16));
//        System.out.println(""+Integer.valueOf("EEEEEE", 16));
//        System.out.println(""+Integer.valueOf("DDDDDD", 16));
//        System.out.println(""+Integer.valueOf("CCCCCC", 16));
//        System.out.println(""+Integer.valueOf("BBBBBB", 16));
//        System.out.println(""+Integer.valueOf("AAAAAA", 16));
//        System.out.println(""+Integer.valueOf("999999", 16));
//        System.out.println(""+Integer.valueOf("888888", 16));
//        System.out.println(""+Integer.valueOf("777777", 16));
//        System.out.println(""+Integer.valueOf("666666", 16));
//        System.out.println(""+Integer.valueOf("555555", 16));
//        System.out.println(""+Integer.valueOf("444444", 16));
//        System.out.println(""+Integer.valueOf("333333", 16));
//        System.out.println(""+Integer.valueOf("222222", 16));
//        System.out.println(""+Integer.valueOf("111111", 16));
//        System.out.println(""+Integer.valueOf("000000", 16));
                

        
//        for (int x = 0; x < height; x++) {
//            StringBuilder sb = new StringBuilder();
//            for (int y = 0; y < width; y++) {
                
          
             for (int y = 0; y < image.getHeight(); y++) {
                for (int x = 0; x < image.getWidth(); x++) {
                String caracter="Z";

                if(image.getRGB(x, y)<0){
                    caracter=" ";
                }
                if(image.getRGB(x, y)<-1118481){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-2236962){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-3355443){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-4473924){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-5592405){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-6710886){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-7829367){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-8947848){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-10066329){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-11184810){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-12303291){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-13421772){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-14540253){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-15658734){
                    caracter=".";
                }
                if(image.getRGB(x, y)<-16777215){
                    caracter=".";
                }
//                System.out.print(""+image.getRGB(x, y)+",");
                

                 System.out.print(""+caracter);

//                sb.append(image.getRGB(x, y) == -16777216 ? " " : "w");
//                sb.append(caracter);
            }
            System.out.println("");
        }

    }
}
